package com.yc.damai.web;

import com.yc.damai.entity.DmProduct;
import com.yc.damai.web.feign.OrderDo;
import com.yc.damai.web.feign.OrderDoImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class ProductAction {

    @Resource
    OrderDo orderDo;

    @Resource
    OrderDoImpl orderDoImpl;

    @RequestMapping("queryNew")
    public List<DmProduct> queryNew(){
        final List<DmProduct> dmProducts = orderDo.queryNew();
        if (dmProducts != null) {
            orderDoImpl.cacheNews(dmProducts);
        }
        return dmProducts;
    }

    @RequestMapping("queryHot")
    public List<DmProduct> queryHot(){
        final List<DmProduct> dmProducts = orderDo.queryHot();
        if (dmProducts != null) {
            orderDoImpl.cacheHots(dmProducts);
        }
        return dmProducts;
    }
}
